package com.semlab.server;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
public class CustomServiceLocator implements
		com.google.web.bindery.requestfactory.shared.ServiceLocator {

	@Override
	public Object getInstance(Class<?> clazz) {
		HttpServletRequest request = RequestFactoryServlet
				.getThreadLocalRequest();
		ServletContext servletContext = request.getSession()
				.getServletContext();
		ApplicationContext context = WebApplicationContextUtils
				.getWebApplicationContext(servletContext);
		return context.getBean(clazz);
	}
}